package com.smartcruise.start.modifyPassword;

import com.smartcruise.util.network.callBack.SimpleCallBack;
import com.smartcruise.util.network.netUtils.NetCollection;
import com.smartcruise.util.network.netUtils.Result;

/**
 * Created by FengChaoQun
 * on 2018/3/17 0017
 */

public class MofidyPasswordPresenterImp implements ModifyPasswordContract.Presenter {

    private ModifyPasswordContract.View mView;
    private boolean findPassword;

    public MofidyPasswordPresenterImp(ModifyPasswordContract.View mView, boolean findPassword) {
        this.mView = mView;
        this.findPassword = findPassword;
    }

    @Override
    public void start() {

    }

    @Override
    public void clickOnSubmit() {
        if (findPassword) {
            NetCollection.findPassword(mView.getPhone(), mView.getPassword(), mView, new SimpleCallBack(mView) {
                @Override
                public void onSuccess(Result result) {
                    mView.showToast("密码重置成功");
                    mView.getActivity().finish();
                }
            });
        } else {
            NetCollection.modifyPassword(mView.getPassword(), mView, new SimpleCallBack(mView) {
                @Override
                public void onSuccess(Result result) {
                    mView.showToast("密码修改成功");
                    mView.getActivity().finish();
                }
            });
        }
    }
}
